using System;
using Core.Runtime;
using Cysharp.Threading.Tasks;
using UnityEngine;
using Random = UnityEngine.Random;

namespace GameLauncher.Runtime
{
    public class PackageOnlyState : HotFixState
    {
        public override async UniTask<StateResult> Execute()
        {
            HotFixUI.RefreshDescLabel("检查资源清单");
            var versionCheckResult = await AssetManager.CheckVersion();
            await UniTask.Delay(TimeSpan.FromSeconds(Random.Range(0.3f, 1.5f)));
            return versionCheckResult.Success
                ? StateResult.Success()
                : StateResult.Failure($"资源清单检查失败{versionCheckResult.Error}");
        }
    }
}